public class Symbol {

    public static Symbol EPSILON = new Symbol("epsilon");
    
    public static Symbol EOF = new Symbol("$");    
    
    private String name;
    private boolean terminal;
    private boolean nonTerm;
    
    public Symbol(String inName) {
        if (inName.equals("epsilon") || inName.equals("$")) {
            // neither terminal nor nonTerminal
        } else if (inName.startsWith("\"")) {
            terminal = true;
            // strip off the quotes
            inName = inName.substring(1,inName.length()-1);
        } else {
            nonTerm = true;
        }
        name = inName;
    }
        
    public String toString() {
        return name;
    }
    
    public boolean isTerm() {
        return terminal;
    }
    
    public boolean isNonTerm() {
        return nonTerm;
    }    
    
    public boolean equals(Object obj) {  
        Symbol sym = (Symbol)obj;
        return name.equals(sym.name);
    }
    
    public int hashCode() {
        return name.hashCode();
    }
}

